﻿using Microsoft.AspNetCore.Mvc;
using Zhaoxi.NET6.Interfaces;

namespace NET6Demo.WebApi.Controllers
{
    /// <summary>
    /// 日志记录
    /// </summary>
    [ApiController]
    [ApiVersion("1.0")]
    [Route("[controller]/v{version:apiVersion}")]
    public class LoggingController : ControllerBase
    {
        private readonly ILogger<LoggingController> _logger;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="logger"></param>
        public LoggingController(ILogger<LoggingController> logger)
        {
            _logger = logger;
        }

        /// <summary>
        /// 获取日志信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetLog()
        {
            _logger.LogError("LogError:=========Get Api被调用===========");
            _logger.LogInformation("LogInformation:=========Get Api被调用===========");
            return new JsonResult(new ApiResult<string>()
            {
                Success = true,
                Data = "日志记录"
            });
        }

    }
}
